<template>
<div>
  <table>
    <tr>
      <td>名称</td>
      <td>价格</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in from">
      <td>{{i.name}}</td>
      <td>{{i.price}}</td>
      <td><button @click="content(i.id)">评论</button></td>
    </tr>
  </table>
</div>
</template>

<script>
export default {
  name: "user_shop",
  data(){
    return{
      from:[],

    }
  },
  methods:{
    get_shop(){
      this.$axios.get('users/shops/')
      .then(res=>{
        if(res.data.code==200){
          this.from = res.data.list
        }
      })
    },
    content(id){
      var userid=localStorage.getItem('userid')
      if(userid){
        this.$router.push({path:'/user_talk',query:{'id':id}})
      }else {
        this.$router.push('/user_login')
      }
    }
  },
  mounted() {
    this.get_shop()
  }
}
</script>

<style scoped>

</style>
